import React, { Component } from 'react'
import {BrowserRouter,Link,Route} from "react-router-dom"



function Home(){
  return <h1>Home</h1>
}
function About(){
  return <h1>About</h1>
}
function NoMatch({location}){
  return <div>404,{location.pathname}不存在</div>
}

export default class RouterSample extends Component {
  render() {
    return (
      <div>
        <BrowserRouter>
          <div>
            <ul>
              <li>
                <Link to="/">首页</Link>
                <Link to="/about">关于</Link>
              </li>
            </ul>
            <Route exact path="/" component={Home}/>
            <Route path="/about" component={About}/>
            <Route component={NoMatch}/>
          </div>
        </BrowserRouter>
      </div>
    )
  }
}
